﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using System.Data.SqlClient;
using System.Data;

namespace ZX.WebApp.EHR
{
    public partial class OneToMore : ZX.Web.UI.Controls.BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                wilf();
            }
        }

        public string MasterEntityID
        {
            get
            {
                return GetStringFromQueryString("id", "");
            }
        }

        /// <summary>
        /// hrEmployeeExperiences的总信息数
        /// </summary>
        public string h1 { get; set; }
        public string h2 { get; set; }
        public string h3 { get; set; }
        public string h4 { get; set; }
        public string h5 { get; set; }
        public string h6 { get; set; }
        public string h7 { get; set; }
        public string h8 { get; set; }
        public string h9 { get; set; }

        /// <summary>
        /// 获得各个模块信息的完整度
        /// </summary>
        /// <param name="aa"></param>
        /// <returns></returns>
        public void wilf()
        {
            StringBuilder sb = new StringBuilder();
            //修改该员工以前图片的状态
            sb.Append("select (select COUNT(*) from hrEmployeeExperiences where EmployeeID = h.ID)h1,");
            sb.Append("(select COUNT(*) from hrEmployeeFamily where EmployeeID = h.ID)h2,");
            sb.Append("(select COUNT(*) from hrEmployeeRecommend where EmployeeID = h.ID)h3,");
            sb.Append("(select COUNT(*) from hrEmployeeGuarantee where EmployeeID = h.ID)h4,");
            sb.Append("(select COUNT(*) from hrEmployeeAdjustPost where EmployeeID = h.ID)h5,");
            sb.Append("(select COUNT(*) from hrEmployeeSanction where EmployeeID = h.ID)h6,");
            sb.Append("(select COUNT(*) from hrEmployeePaymentInfo where EmployeeID = h.ID)h7,");
            sb.Append("(select COUNT(*) from hrEmployeeFileStreams where Precordid = h.ID and Datstate=0)h8, ");
            sb.Append("(select COUNT(*) from hrEmployeeExperiences where EmployeeID = h.ID)h9 ");
            sb.Append("from hrEmployee h where ID=@ID");

            //打开数据库
            string connString = System.Configuration.ConfigurationManager.ConnectionStrings["ConnString"].ToString();
            using (SqlConnection conn = new SqlConnection(connString))
            {
                conn.Open();
                SqlCommand com = new SqlCommand(sb.ToString(), conn);
                com.Parameters.Add("ID", SqlDbType.UniqueIdentifier);
                com.Parameters["ID"].Value = Guid.Parse(MasterEntityID);

                SqlDataReader dr = com.ExecuteReader();
                while (dr.Read())
                {
                    h1 = Convert.ToInt32(dr["h1"].ToString()) == 0 ? "color:red" : "";
                    h2 = Convert.ToInt32(dr["h2"].ToString()) == 0 ? "color:red" : "";
                    h3 = Convert.ToInt32(dr["h3"].ToString()) == 0 ? "color:red" : "";
                    h4 = Convert.ToInt32(dr["h4"].ToString()) == 0 ? "color:red" : "";
                    h5 = Convert.ToInt32(dr["h5"].ToString()) == 0 ? "color:red" : "";
                    h6 = Convert.ToInt32(dr["h6"].ToString()) == 0 ? "color:red" : "";
                    h7 = Convert.ToInt32(dr["h7"].ToString()) == 0 ? "color:red" : "";
                    h8 = Convert.ToInt32(dr["h8"].ToString()) == 0 ? "color:red" : "";
                    h9 = Convert.ToInt32(dr["h9"].ToString()) == 0 ? "color:red" : "";
                }
                dr.Close();
            }
        }
    }
}